package com.system.util.freemarker.template;

import com.alibaba.fastjson.JSONObject;
import com.component.domain.MChannel;
import com.component.service.MChannelService;
import com.system.config.freemarker.DirectiveHandler;
import com.system.config.freemarker.FreemarkerScan;
import com.system.config.freemarker.TemplateDirective;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Classname HotChannelListTemplate
 * @Description TODO
 * @Date 2023/9/28 15:08
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@FreemarkerScan("hotchannellist")
public class HotChannelListTemplate extends TemplateDirective {

    @Autowired
    private MChannelService mChannelService;

    @Override
    public String getName() {
        return "hotchannellist";
    }

    @Override
    public void execute(DirectiveHandler handler) throws Exception {
        List<MChannel> mChannelList=mChannelService.getHotMChannels();
        Map<String, Object> map = new HashMap<>();
        map.put("records", mChannelList);
        handler.put(RESULTS,map).render();
    }
}
